{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3a79ef54-63e6-429f-ba9f-590b736a7f29",
   "metadata": {},
   "source": [
    "## 1.3 安装TensorFlow2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c90a18b9-d8e8-431c-856c-35f1e4ed05e1",
   "metadata": {},
   "source": [
    "### 1.任务描述\n",
    "- 创建虚拟环境tf2（在目录D:\\deve\\Python下）。\n",
    "- 激活虚拟环境tf2。\n",
    "- 安装TensorFlow 2.6.0。\n",
    "- 进入Python环境，导入TensorFlow模块，输出TensorFlow版本信息。"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "8d7baa9c-93a2-42f3-a3c1-231cdb587f2d",
   "metadata": {},
   "source": [
    "### 2.知识准备\n",
    "\n",
    "见教程。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74ad989a-9b82-43e1-b841-e74284cd5936",
   "metadata": {},
   "source": [
    "### 3.任务分析\n",
    "\n",
    "建议在特定的虚拟环境中安装TensorFlow。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "435c6090-cfda-4f46-a550-22a368e41e4a",
   "metadata": {},
   "source": [
    "### 4.任务实施\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec75eb6c-5da3-467d-a471-ca3b47242dd6",
   "metadata": {},
   "source": [
    "1. 创建并激活虚拟环境tf2\n",
    "\n",
    "进入D:\\deve\\Python目录，创建名为tf2的虚拟环境："
   ]
  },
  {
   "cell_type": "raw",
   "id": "febafc02-eed4-4c77-b241-0a825425a895",
   "metadata": {},
   "source": [
    "D:\\deve\\Python\\python -m venv tf2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92c8ce99-8793-4da2-a3e0-ec20ab1c4659",
   "metadata": {},
   "source": [
    "2. 激活虚拟环境tf2\n",
    "\n",
    "进入虚拟环境tf2下的Scripts目录，进行激活："
   ]
  },
  {
   "cell_type": "raw",
   "id": "d5851eae-461a-42db-bdb3-ed4bbf969ec8",
   "metadata": {},
   "source": [
    "D:\\deve\\Python\\tf2\\Scripts>activate\n",
    "(tf2) D:\\deve\\Python\\tf2\\Scripts>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8f95bbc-5dcd-4920-bb0a-f78febb22eb5",
   "metadata": {},
   "source": [
    "3. 安装TensorFlow 2\n",
    "\n",
    "安装TensorFlow 2.6.0版本："
   ]
  },
  {
   "cell_type": "raw",
   "id": "cea85882-4e24-4a90-a91c-903885287e0f",
   "metadata": {},
   "source": [
    "(tf2) D:\\deve\\Python\\tf2\\Scripts>pip install tensorflow==2.6.0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2c68092-397c-4563-b419-b9416aeb6aa6",
   "metadata": {},
   "source": [
    "4. 查看TensorFlow 2版本\n",
    "\n",
    "进入Python环境，执行如下命令："
   ]
  },
  {
   "cell_type": "raw",
   "id": "2c82ce9e-4ff9-400c-b454-672000df35cd",
   "metadata": {},
   "source": [
    "(tf2) D:\\deve\\Python\\tf2\\Scripts>python\n",
    ">>> import tensorflow as tf\n",
    ">>> tf.__version__\n",
    "'2.6.0'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68b99659-b0b2-4cd9-80aa-76bff22c31db",
   "metadata": {},
   "source": [
    "若看到TensorFlow的版本信息，则表示安装成功。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
